//------------------------------------------------------------------------------
// X2D Game Engine
// Copyright (C) 2006-2007 Janusz Kowalski
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------

#include <cassert>

#include "x2d_BgLayer.h"
#include "global.h"

namespace x2d {

//-----------------------------------------------------------------------------
// BgScrap class
//-----------------------------------------------------------------------------

BgScrap::BgScrap(const char *path, int x, int y, double scale, int repeatX, int repeatY) {
  image_ = Image(path);
  x_ = x;
  y_ = y;
  scaleX_ = scaleY_ = scale;
  repeatX_ = repeatX;
  repeatY_ = repeatY;
}


BgLayer::BgLayer() {
  imageList_.add(ImageXY(0,0,X2D_PATH_BACKGROUND "abstract.png"));
  x_=0; y_=0; w_=256; h_=256; relX_=0.1; relY_=0.1;
  repeatX_=true; repeatY_=true;
  assert(relX_>=0); assert(relY_>=0);
}

BgLayer::~BgLayer() {
}

double BgLayer::getDeltaX(double x0) {
  return -x0*relX_+x_;
}

double BgLayer::getDeltaY(double y0) {
  return -y0*relY_+y_;
}

} // namespace x2d
